package Function.ItemUse;

import FCRendering.FCRBattleOrderConstant;
import VWorldGameStudio.*;

import static FCRendering.FCRMaster.fcv;

public class ToolNuanBaoBao extends AItemUse{
    @Override
    public ItemUseResult directUse() {
        return useForPlayerTarget(keepPlayer);
    }

    @Override
    public ItemUseResult useInMapTarget(int x, int y) {
        return useForPlayerTarget(keepPlayer);
    }

    @Override
    public ItemUseResult useForMonsterTarget(FCBattleOrder battleOrder, FCMonster m) {
        return new ItemUseResult().useless();
    }

    @Override
    public ItemUseResult useForPlayerTarget(FCPlayerInfo p) {
        fcv.closeAllShowWindw();
        if(!fcv.isBattle()){
            fcv.getMessage().add("只能在战斗中使用，什么也没发生");
            fcv.showMessage();
            return new ItemUseResult().useless();
        }
        if(p.isDeath()){
            fcv.getMessage().add("不能给死者使用,什么也没发生");
            fcv.showMessage();
            return new ItemUseResult().useless();
        }
        FCPlayerBattleWrap wrap = FCPlayerBattleWrap.findBattleWrapByName(p.getAliasUID(), p.getName());
        int isFire = wrap.getLongTermVal(FCRBattleOrderConstant.S_Frozen);
        if(isFire != -1) {
            wrap.removeLongTermState(FCRBattleOrderConstant.S_Frozen);
            fcv.getMessage().add("暖和了" + p.getChName());
            fcv.showMessage();
            useAfter();
        }else {
            fcv.getMessage().add(p.getChName() + "没着冷冻，什么也没发生");
            fcv.showMessage();
        }
        return new ItemUseResult();
    }

    @Override
    public ItemUseResult useForTankTarget(FCTank t) {
        return useForPlayerTarget(keepPlayer);
    }
}
